home *** CD-ROM | disk | FTP | other *** search
- Path: tank.news.pipex.net!pipex!demon!fredblog.demon.co.uk
- From: mark@fredblog.demon.co.uk (Mark Winfield)
- Newsgroups: comp.lang.c
- Subject: What's so different about 2-D arrays???
- Date: Sun, 31 Dec 1995 23:18:43 GMT
- Organization: - none -
- Message-ID: <820451938.20697@fredblog.demon.co.uk>
- Reply-To: mark@fredblog.demon.co.uk
- NNTP-Posting-Host: fredblog.demon.co.uk
- X-NNTP-Posting-Host: fredblog.demon.co.uk
- X-Newsreader: Forte Free Agent 1.0.82
-
- I have been teaching myself 'C' over the last month. Just before Xmas
- I thought that I had it worked out and that all I had to do was
- practice. I decided to write a program that would record chess games,
- it would allow move branching as well. I decided upon this because it
- should use everything I have learnt except DOS calls.
- Now for the problem,
-
- //My own chess recorder program
-
- #include <stdio.h>
- #include <ctype.h>
-
- /*Prototypes*/
- void setup(char pos[8][8]);
-
-
- void main()
- {
- char pos[8][8];
-
- setup(pos);
-
-
- printf("\nWell Done!!");
- }
-
- void setup(char pos[8][8])
- {
- int x,y;
-
- pos[1][8]=pos[8][8]='r';
- pos[2][8]=pos[7][8]='n';
- pos[3][8]=pos[6][8]='b';
-
- pos[1][1]=pos[8][1]='R';
- pos[2][1]=pos[7][1]='N';
- pos[3][1]=pos[6][1]='B';
-
- for(x=1;x<9;x++){
- pos[x][7]='a';
- pos[x][2]='A';
-
- for(y=3;y<7;y++)
- pos[x][y]=' ';
- }
-
- pos[4][8]='q';
- pos[5][8]='k';
-
- pos[4][1]='Q';
- pos[5][1]='K';
- }
-
- This program does not work with a '.c' or '.cpp' extension. If I run
- the program from dos I get well done and then something about NULL
- pointers and the program hangs, so I have to reset. And if I run the
- program from within the TURBO C++ enviroment the program hangs after
- printing well done.
-
- I have written a similar program since, as a test, which uses a 1-D
- array with no problems. Can someone help me with this problem.
-
-